<?
namespace Api
{
	/** Session
	 * @desc: Session manager
	**/
	
	class	Session
	{
		public function __construct(){
			$this->SessionRenew();
		}
		
		public function	__set($name,$value){
            \Api\Session::SessionRenew();
			$_SESSION[$name]=$value;
		}
		
		public function __get($name)
		{
           
			if(array_key_exists($name, $_SESSION)) return $_SESSION[$name];
			return null;
		}
		
		static public function set($name,$value)
		{
			$_SESSION[$name] = $value;
		}
        
 	      static public function setRef($name, &$value)
		{
			$_SESSION[$name] = $value;
		}
		
		static public function get($name)
		{
             \Api\Session::SessionRenew();
			if(array_key_exists($name, $_SESSION)) return $_SESSION[$name];
			return null;
		}
        static public function getRef($name)
		{
             \Api\Session::SessionRenew();
			if(array_key_exists($name, $_SESSION)) 
            {
                $rel = &$_SESSION[$name];
                return $rel;
            }
			return null;
		}
        
        static public function SessionRenew()
        {
            if(!session_id()) session_start();
        }
		
		static public function SessionExists(){
			return session_id();
		}
				
	}
}
?>